package com.yuchen.bearrecord.controller;

import com.yuchen.bearrecord.config.Result;
import com.yuchen.bearrecord.entity.User;
import com.yuchen.bearrecord.service.impl.UserServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserServiceImpl userService;

    @PostMapping("/login")
    @ResponseBody
    public Result login() {
        return userService.login();
    }

    @GetMapping("getUserType")
    @ResponseBody
    public Result getUserType(){
        return userService.getUserType();
    }

    @GetMapping("getUserList")
    @ResponseBody
    public Result getUserList(){
        return userService.getUserList();
    }

    @PutMapping("/updateUserType")
    @ResponseBody
    public Result updateUserDrug(@RequestBody User user) {
        return userService.updateUserType(user);
    }

    @DeleteMapping("/deleteUser")
    @ResponseBody
    public Result deleteDrug(@RequestParam("openid") String openid) {
        return userService.deleteUser(openid);
    }
}
